/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pa165.dominatingspecies.frontend.element;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.springframework.security.access.prepost.PreAuthorize;
import pa165.dominating.species.enums.ElementType;
import pa165.dominating.species.service.ElementService;
import pa165.dominating.species.tos.ElementTo;
import pa165.dominatingspecies.frontend.pages.BasePage;

/**
 *
 * @author Ondrej Prazak
 */
@PreAuthorize("hasRole('WORKER')")
public class ElementDetailsPage extends BasePage {

    @SpringBean(name = "elementService")
    private ElementService elementService;
    private ElementTo ele;

    public ElementDetailsPage(Long id) {
        if (id != null) {
            ele = elementService.getElementToById(id);
        }
        add(new Label("identif", ele.getId().toString()));
        add(new Label("descript", ele.getDescription()));
        add(new Label("type", new EnumPropertyModel<ElementType>(ele, "type", this)));

        Link<BasePage> goBack = new Link<BasePage>("goBack") {
            @Override
            public void onClick() {
                setResponsePage(new ElementsPage());
            }
        };
        add(goBack);
    }
}
